<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@taglib prefix="logic" uri="http://struts.apache.org/tags-logic" %>
<%@taglib prefix="html" uri="http://struts.apache.org/tags-html"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<bean:message key="languages" />:

<c:set var="localeCode" value="${sessionScope['org.apache.struts.action.LOCALE']}" scope="session" />
<c:set var="availableLanguages" value="en,ru" />

<c:forEach var="lang" items="${availableLanguages}">
	<!-- c:if test="${lang == fn:substring(localeCode, 0, 2)}" for locale codes like en_EN -->
	
	<c:if test="${lang == localeCode}">
		<html:link action="/locale.do?method=${lang}"><b style="color: red">${lang}</b></html:link> 
	</c:if>
	<c:if test="${!(lang == localeCode)}">
		<html:link action="/locale.do?method=${lang}">${lang}</html:link>
	</c:if>
</c:forEach>

<br/>
<logic:notPresent name="auth" scope="session">
	<b>
		<bean:message key="please.login" />
	</b>
	<a href="login.jsp"><bean:message key="login" /></a>
</logic:notPresent>

<logic:present name="auth" scope="session">
<html:link href="logout.do"><bean:message key="logout" /></html:link>
<b>
<bean:message key="welcome" />
${auth.userName}
</b>
</logic:present>



